package com.vitabuybuy.tv.dialog

import android.content.Context
import android.view.View
import android.view.animation.Animation
import android.widget.ImageView
import android.widget.TextView
import com.vitabuybuy.tv.R
import razerdp.basepopup.BasePopupWindow
import razerdp.util.animation.AnimationHelper
import razerdp.util.animation.TranslationConfig

/**
 * 详情规则弹出框
 */
class GroupRulePopup(
    context: Context,
    val content: String
) : BasePopupWindow(context) {
    private lateinit var ivClose: ImageView
    private lateinit var tvRule: TextView

    override fun onCreateContentView(): View {
        return createPopupById(R.layout.popup_group_rule)
    }

    init {
        tvRule.text = content
    }

    override fun onViewCreated(contentView: View) {
        super.onViewCreated(contentView)

        ivClose = findViewById(R.id.ivClose)
        tvRule = findViewById(R.id.tvRule)

        setViewClickListener(View.OnClickListener { this.dismiss() }, ivClose)
    }

    override fun onCreateShowAnimation(): Animation {
        return AnimationHelper.asAnimation()
            .withTranslation(TranslationConfig.FROM_BOTTOM)
            .toShow()
    }

    override fun onCreateDismissAnimation(): Animation {
        return AnimationHelper.asAnimation()
            .withTranslation(TranslationConfig.TO_BOTTOM)
            .toDismiss()
    }
}